<!--
* @author wn
* @date 2022/11/17 11:21:46
* @description: 图表2
!-->
<template>
	<div ref="line" style="height: 330px"></div>
</template>
<script setup>
import * as echarts from 'echarts'
import { echartsLine, getEchartsDataTwo } from '@/network/home'
import { nextTick, ref } from 'vue'

// 组件实例 传入  echarts init
const line = ref('')
let myEcharts = null
nextTick(() => {
	myEcharts = echarts.init(line.value)
})
// 获取数据
getEchartsDataTwo().then(({ day, num }) => {
	// 随便 一个 num数据 的所有 key
	const keys = Object.keys(num)
	echartsLine.xAxis.data = day
	keys.forEach((key, index) => {
		echartsLine.series[index].name = key
		echartsLine.series[index].data = num[key]
	})

	myEcharts.setOption(echartsLine)
})
// 监听 页面 大小 改变
/* window.addEventListener('resize', () => {
	myEcharts.resize()
}) */
</script>
<style scoped lang="scss"></style>
